package model

import (
	"context"
	"github.com/redis/go-redis/v9"
	"user_bff/user_proto"
)

var (
	RedisClient *redis.Client
)

func InitRedis() {
	RedisClient = redis.NewClient(&redis.Options{
		Addr:     "localhost:6379",
		Password: "", // no password set
		DB:       0,  // use default DB
	})
}

// redis存储列表
func SetBookList(b []*user_proto.BookInfo) {
	for _, v := range b {
		RedisClient.ZAdd(context.Background(), "list", redis.Z{
			Score:  float64(v.Hot),
			Member: v,
		})
	}
}
